@extends('Admin.index')

@section('css')

@endsection

@section('content')
    <div id="wrapper">

        <div class="row setting_1">
            <div class="col-lg-12" id="detail">

                <form onsubmit="return false;" class="form-horizontal">

                    <div class="form-group">
                        <label class="col-sm-1 control-label" style="font-size: 15px;width: 150px;"> 房间收费：</label>
                        <div class="col-sm-1">
                            <input type="text" class="form-control" id="room" placeholder="请输入数字"  value="{{$num or 0}}" >
                        </div>
                        <span style="font-size: 15px;margin-left:-144px;margin-top:10px;"> %</span>
                        <div class="col-sm-1">
                            <button type="button" class="btn btn-success ml10" onclick="setting.save();">保存</button>
                        </div>
                    </div>
                </form>

            </div>

        </div>


    </div>
@endsection

@section('js')
    <script>
        var setting ={
            save:function () {
                var num = $('#room').val();

                if (!E.isInt(num)) {
                    layer.alert('请输入有效数字', {icon: 2, offset: '70px'});
                    return false;
                }

                if (num > 100) {
                    layer.alert('请输入小于100数字', {icon: 2, offset: '70px'});
                    return false;
                }

                E.ajax({
                    type: 'get',
                    url: '/admin/room/save/'+ num,
                    success: function (res) {
                        if (res.code == 200) {
                            layer.alert('保存成功', {icon: 1, offset: '70px', time: 1500});
                            location.reload();
                        } else {
                            layer.alert(res.message, {icon: 2, offset: '70px'});
                        }
                    }
                });
            }
        }
    </script>
@endsection